<template>
  <div class="app-container">
    <!-- 统计卡片 -->
    <div class="stats-container">
      <el-row :gutter="20">
        <el-col :span="6">
          <el-card class="stat-card total-card" shadow="hover">
            <div class="stat-content">
              <div class="stat-icon">
                <i class="el-icon-user"></i>
              </div>
              <div class="stat-info">
                <div class="stat-number">{{ total }}</div>
                <div class="stat-label">总客户数</div>
              </div>
            </div>
          </el-card>
        </el-col>
        <el-col :span="6">
          <el-card class="stat-card visit-card" shadow="hover">
            <div class="stat-content">
              <div class="stat-icon">
                <i class="el-icon-location"></i>
              </div>
              <div class="stat-info">
                <div class="stat-number">{{ visitCount }}</div>
                <div class="stat-label">现场拜访</div>
              </div>
            </div>
          </el-card>
        </el-col>
        <el-col :span="6">
          <el-card class="stat-card phone-card" shadow="hover">
            <div class="stat-content">
              <div class="stat-icon">
                <i class="el-icon-phone"></i>
              </div>
              <div class="stat-info">
                <div class="stat-number">{{ phoneCount }}</div>
                <div class="stat-label">电话沟通</div>
              </div>
            </div>
          </el-card>
        </el-col>
        <el-col :span="6">
          <el-card class="stat-card amount-card" shadow="hover">
            <div class="stat-content">
              <div class="stat-icon">
                <i class="el-icon-money"></i>
              </div>
              <div class="stat-info">
                <div class="stat-number">{{ totalAmount }}</div>
                <div class="stat-label">总核销金额</div>
              </div>
            </div>
          </el-card>
        </el-col>
      </el-row>
    </div>

    <!-- 搜索卡片 -->
    <el-card class="search-card" shadow="hover">
      <div slot="header" class="card-header">
        <span class="card-title">
          <i class="el-icon-search"></i>
          搜索条件
        </span>
        <div class="header-actions">
          <el-button type="text" @click="toggleSearch">
            {{ showSearch ? '收起' : '展开' }}
            <i :class="showSearch ? 'el-icon-arrow-up' : 'el-icon-arrow-down'"></i>
          </el-button>
          <el-button type="text" @click="resetQuery" icon="el-icon-refresh">重置</el-button>
        </div>
      </div>
      
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="客户名称" prop="customerName">
              <el-input
                v-model="queryParams.customerName"
                placeholder="请输入客户名称"
                clearable
                @keyup.enter.native="handleQuery"
                prefix-icon="el-icon-office-building"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="跟进人" prop="followUpPerson">
              <el-input
                v-model="queryParams.followUpPerson"
                placeholder="请输入跟进人"
                clearable
                @keyup.enter.native="handleQuery"
                prefix-icon="el-icon-user"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="跟进类型" prop="followUpType">
              <el-select
                v-model="queryParams.followUpType"
                placeholder="请选择跟进类型"
                clearable
                style="width: 100%"
              >
                <el-option label="现场拜访" value="现场拜访"></el-option>
                <el-option label="电话沟通" value="电话沟通"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item>
              <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
              <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-card>

    <!-- 操作按钮卡片 -->
    <el-card class="action-card" shadow="hover">
      <div class="action-buttons">
        <div class="left-buttons">
          <el-button
            type="primary"
            icon="el-icon-plus"
            size="mini"
            @click="handleAdd"
            v-hasPermi="['customer:customer_records:add']"
          >新增记录</el-button>
          <el-button
            type="success"
            icon="el-icon-edit"
            size="mini"
            :disabled="single"
            @click="handleUpdate"
            v-hasPermi="['customer:customer_records:edit']"
          >修改</el-button>
          <el-button
            type="danger"
            icon="el-icon-delete"
            size="mini"
            :disabled="multiple"
            @click="handleDelete"
            v-hasPermi="['customer:customer_records:remove']"
          >删除</el-button>
          <el-button
            type="warning"
            icon="el-icon-download"
            size="mini"
            @click="handleExport"
            v-hasPermi="['customer:customer_records:export']"
          >导出</el-button>
          <el-button type="info" icon="el-icon-view" size="mini" @click="handleView" :disabled="single">查看详情</el-button>
        </div>
        <div class="right-buttons">
          <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
        </div>
      </div>
    </el-card>

    <!-- 数据展示卡片 -->
    <el-card class="data-card" shadow="hover">
      <div slot="header" class="card-header">
        <span class="card-title">
          <i class="el-icon-document"></i>
          客户跟进记录列表
        </span>
        <span class="card-subtitle">共 {{ total }} 条记录</span>
      </div>

      <el-table 
        v-loading="loading" 
        :data="customer_recordsList" 
        @selection-change="handleSelectionChange"
        stripe
        border
        class="custom-table"
      >
        <el-table-column type="selection" width="55" align="center" />
        
        <el-table-column label="跟进类型" align="center" prop="followUpType" min-width="100">
          <template slot-scope="scope">
            <el-tag 
              :type="scope.row.followUpType === '现场拜访' ? 'success' : 'info'"
              size="mini"
              effect="dark"
            >
              <i :class="scope.row.followUpType === '现场拜访' ? 'el-icon-location' : 'el-icon-phone'"></i>
              {{ scope.row.followUpType }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column label="客户名称" align="center" prop="customerName" min-width="150" show-overflow-tooltip>
          <template slot-scope="scope">
            <div class="customer-name">
              <i class="el-icon-office-building"></i>
              <span>{{ scope.row.customerName }}</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="客户联系人" align="center" prop="contactPerson" min-width="100">
          <template slot-scope="scope">
            <div class="contact-person">
              <i class="el-icon-user"></i>
              <span>{{ scope.row.contactPerson }}</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="联系人电话" align="center" prop="contactPhone" min-width="130">
          <template slot-scope="scope">
            <div class="contact-phone">
              <i class="el-icon-phone"></i>
              <span>{{ scope.row.contactPhone }}</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="客户地址" align="center" prop="customerAddress" min-width="150" show-overflow-tooltip />
        <el-table-column label="咨询产品" align="center" prop="consultedProduct" min-width="120" show-overflow-tooltip />
        <el-table-column label="客户来源" align="center" prop="customerSource" min-width="100">
          <template slot-scope="scope">
            <el-tag 
              class="customer-source-tag"
              size="mini" 
              effect="dark"
            >
              <i class="el-icon-connection"></i>
              {{ scope.row.customerSource }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column label="客户行业" align="center" prop="customerIndustry" min-width="100" show-overflow-tooltip />
        <el-table-column label="实际出差日期" align="center" prop="actualTripDate" width="120">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.actualTripDate, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="跟进人" align="center" prop="followUpPerson" min-width="100" />
        <el-table-column label="跟进目的" align="center" prop="followUpPurpose" min-width="120" show-overflow-tooltip />
        <el-table-column label="跟进计划" align="center" prop="followUpPlan" min-width="120" show-overflow-tooltip />
        <el-table-column label="跟进结果" align="center" prop="followUpResult" min-width="120" show-overflow-tooltip />
        <el-table-column label="打卡地址" align="center" prop="checkInAddress" min-width="120" show-overflow-tooltip />
        <el-table-column label="跟进时间" align="center" prop="followUpTime" width="120">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.followUpTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="下次跟进时间" align="center" prop="nextFollowUpDate" width="120">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.nextFollowUpDate, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="核销金额" align="center" prop="reimbursementAmount" min-width="100">
          <template slot-scope="scope">
            <span class="amount-text">¥{{ scope.row.reimbursementAmount }}</span>
          </template>
        </el-table-column>
        
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="180">
          <template slot-scope="scope">
            <el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row)">查看</el-button>
            <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['customer:customer_records:edit']">修改</el-button>
            <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['customer:customer_records:remove']">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </el-card>

    <!-- 添加或修改出差记录核销对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <el-tabs v-model="activeTab" type="border-card">
          <el-tab-pane label="基本信息" name="basic">
            <el-row :gutter="20">
              <el-col :span="12">
                <el-form-item label="跟进类型" prop="followUpType">
                  <el-select v-model="form.followUpType" placeholder="请选择跟进类型" style="width: 100%">
                    <el-option label="现场拜访" value="现场拜访"></el-option>
                    <el-option label="电话沟通" value="电话沟通"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="客户名称" prop="customerName">
                  <el-input v-model="form.customerName" placeholder="请输入客户名称" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row :gutter="20">
              <el-col :span="12">
                <el-form-item label="客户联系人" prop="contactPerson">
                  <el-input v-model="form.contactPerson" placeholder="请输入客户联系人" />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="联系人电话" prop="contactPhone">
                  <el-input v-model="form.contactPhone" placeholder="请输入联系人电话" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row :gutter="20">
              <el-col :span="12">
                <el-form-item label="客户来源" prop="customerSource">
                  <el-select v-model="form.customerSource" placeholder="请选择客户来源" style="width: 100%">
                    <el-option label="网络广告" value="网络广告"></el-option>
                    <el-option label="展会认识" value="展会认识"></el-option>
                    <el-option label="客户介绍" value="客户介绍"></el-option>
                    <el-option label="朋友推荐" value="朋友推荐"></el-option>
                    <el-option label="线上咨询" value="线上咨询"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="客户行业" prop="customerIndustry">
                  <el-input v-model="form.customerIndustry" placeholder="请输入客户行业" />
                </el-form-item>
              </el-col>
            </el-row>
          </el-tab-pane>
          
          <el-tab-pane label="地址信息" name="address">
            <el-row :gutter="20">
              <el-col :span="24">
                <el-form-item label="客户地址" prop="customerAddress">
                  <el-input v-model="form.customerAddress" placeholder="请输入客户地址" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row :gutter="20">
              <el-col :span="12">
                <el-form-item label="咨询产品" prop="consultedProduct">
                  <el-input v-model="form.consultedProduct" placeholder="请输入咨询产品" />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="打卡地址" prop="checkInAddress">
                  <el-input v-model="form.checkInAddress" placeholder="请输入打卡地址" />
                </el-form-item>
              </el-col>
            </el-row>
          </el-tab-pane>
          
          <el-tab-pane label="跟进信息" name="follow">
            <el-row :gutter="20">
              <el-col :span="12">
                <el-form-item label="实际出差日期" prop="actualTripDate">
                  <el-date-picker clearable
                    v-model="form.actualTripDate"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="请选择实际出差日期"
                    style="width: 100%">
                  </el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="跟进人" prop="followUpPerson">
                  <el-input v-model="form.followUpPerson" placeholder="请输入跟进人" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row :gutter="20">
              <el-col :span="12">
                <el-form-item label="跟进时间" prop="followUpTime">
                  <el-date-picker clearable
                    v-model="form.followUpTime"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="请选择跟进时间"
                    style="width: 100%">
                  </el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="下次跟进时间" prop="nextFollowUpDate">
                  <el-date-picker clearable
                    v-model="form.nextFollowUpDate"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="请选择下次跟进时间"
                    style="width: 100%">
                  </el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row :gutter="20">
              <el-col :span="24">
                <el-form-item label="跟进目的" prop="followUpPurpose">
                  <el-input v-model="form.followUpPurpose" placeholder="请输入跟进目的" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row :gutter="20">
              <el-col :span="24">
                <el-form-item label="跟进计划" prop="followUpPlan">
                  <el-input v-model="form.followUpPlan" type="textarea" :rows="3" placeholder="请输入跟进计划" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row :gutter="20">
              <el-col :span="24">
                <el-form-item label="跟进结果" prop="followUpResult">
                  <el-input v-model="form.followUpResult" type="textarea" :rows="3" placeholder="请输入跟进结果" />
                </el-form-item>
              </el-col>
            </el-row>
          </el-tab-pane>
          
          <el-tab-pane label="核销信息" name="reimbursement">
            <el-row :gutter="20">
              <el-col :span="12">
                <el-form-item label="核销金额" prop="reimbursementAmount">
                  <el-input v-model="form.reimbursementAmount" placeholder="请输入核销金额" />
                </el-form-item>
              </el-col>
            </el-row>
          </el-tab-pane>
        </el-tabs>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 查看详情对话框 -->
    <el-dialog title="客户跟进详情" :visible.sync="viewOpen" width="800px" append-to-body>
      <div class="customer-detail">
        <el-descriptions :column="2" border>
          <el-descriptions-item label="跟进类型">{{ viewForm.followUpType }}</el-descriptions-item>
          <el-descriptions-item label="客户名称">{{ viewForm.customerName }}</el-descriptions-item>
          <el-descriptions-item label="客户联系人">{{ viewForm.contactPerson }}</el-descriptions-item>
          <el-descriptions-item label="联系人电话">{{ viewForm.contactPhone }}</el-descriptions-item>
          <el-descriptions-item label="客户地址" :span="2">{{ viewForm.customerAddress }}</el-descriptions-item>
          <el-descriptions-item label="咨询产品">{{ viewForm.consultedProduct }}</el-descriptions-item>
          <el-descriptions-item label="客户来源">{{ viewForm.customerSource }}</el-descriptions-item>
          <el-descriptions-item label="客户行业">{{ viewForm.customerIndustry }}</el-descriptions-item>
          <el-descriptions-item label="实际出差日期">{{ parseTime(viewForm.actualTripDate, '{y}-{m}-{d}') }}</el-descriptions-item>
          <el-descriptions-item label="跟进人">{{ viewForm.followUpPerson }}</el-descriptions-item>
          <el-descriptions-item label="跟进目的">{{ viewForm.followUpPurpose }}</el-descriptions-item>
          <el-descriptions-item label="跟进计划">{{ viewForm.followUpPlan }}</el-descriptions-item>
          <el-descriptions-item label="跟进结果">{{ viewForm.followUpResult }}</el-descriptions-item>
          <el-descriptions-item label="打卡地址">{{ viewForm.checkInAddress }}</el-descriptions-item>
          <el-descriptions-item label="跟进时间">{{ parseTime(viewForm.followUpTime, '{y}-{m}-{d}') }}</el-descriptions-item>
          <el-descriptions-item label="下次跟进时间">{{ parseTime(viewForm.nextFollowUpDate, '{y}-{m}-{d}') }}</el-descriptions-item>
          <el-descriptions-item label="核销金额">¥{{ viewForm.reimbursementAmount }}</el-descriptions-item>
        </el-descriptions>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="viewOpen = false">关 闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listCustomer_records, getCustomer_records, delCustomer_records, addCustomer_records, updateCustomer_records } from "@/api/customer/customer_records"

export default {
  name: "Customer_records",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 出差记录核销表格数据
      customer_recordsList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 当前激活的标签页
      activeTab: 'basic',
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        followUpType: null,
        customerName: null,
        followUpPerson: null,
      },
      // 统计数据
      visitCount: 0,
      phoneCount: 0,
      totalAmount: 0,
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        followUpType: [
          { required: true, message: "跟进类型不能为空", trigger: "blur" }
        ],
        customerName: [
          { required: true, message: "客户名称不能为空", trigger: "blur" }
        ],
        customerSource: [
          { required: true, message: "客户来源不能为空", trigger: "blur" }
        ],
        followUpPerson:[
          { required: true, message: "跟进人不能为空", trigger: "blur" }
        ],
        followUpPurpose:[
          { required: true, message: "跟进目的不能为空", trigger: "blur" }
        ],
        followUpPlan:[
          { required: true, message: "跟进计划不能为空", trigger: "blur" }
        ],
        followUpResult:[
          { required: true, message: "跟进结果不能为空", trigger: "blur" }
        ]
      },
      viewOpen: false, // 新增：查看详情弹窗开关
      viewForm: {},    // 新增：查看详情表单数据
    }
  },
  created() {
    this.getList()
  },
  methods: {
    /** 查询出差记录核销列表 */
    getList() {
      this.loading = true
      listCustomer_records(this.queryParams).then(response => {
        this.customer_recordsList = response.rows
        this.total = response.total
        this.calculateStats()
        this.loading = false
      })
    },
    /** 计算统计数据 */
    calculateStats() {
      this.visitCount = this.customer_recordsList.filter(item => item.followUpType === '现场拜访').length
      this.phoneCount = this.customer_recordsList.filter(item => item.followUpType === '电话沟通').length
      this.totalAmount = this.customer_recordsList.reduce((sum, item) => {
        return sum + (parseFloat(item.reimbursementAmount) || 0)
      }, 0).toFixed(2)
    },
    // 取消按钮
    cancel() {
      this.open = false
      this.reset()
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        followUpType: null,
        customerName: null,
        contactPerson: null,
        contactPhone: null,
        customerAddress: null,
        consultedProduct: null,
        customerSource: null,
        customerIndustry: null,
        actualTripDate: null,
        followUpPerson: null,
        followUpPurpose: null,
        followUpPlan: null,
        followUpResult: null,
        checkInAddress: null,
        followUpTime: null,
        nextFollowUpDate: null,
        reimbursementAmount: null
      }
      this.resetForm("form")
      this.activeTab = 'basic'
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm")
      this.handleQuery()
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset()
      this.open = true
      this.title = "添加客户跟进记录"
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset()
      const id = row.id || this.ids
      getCustomer_records(id).then(response => {
        this.form = response.data
        this.open = true
        this.title = "修改客户跟进记录"
      })
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateCustomer_records(this.form).then(response => {
              this.$modal.msgSuccess("修改成功")
              this.open = false
              this.getList()
            })
          } else {
            addCustomer_records(this.form).then(response => {
              this.$modal.msgSuccess("新增成功")
              this.open = false
              this.getList()
            })
          }
        }
      })
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids
      this.$modal.confirm('是否确认删除客户跟进记录编号为"' + ids + '"的数据项？').then(function() {
        return delCustomer_records(ids)
      }).then(() => {
        this.getList()
        this.$modal.msgSuccess("删除成功")
      }).catch(() => {})
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('customer/customer_records/export', {
        ...this.queryParams
      }, `customer_records_${new Date().getTime()}.xlsx`)
    },
    /** 切换搜索显示 */
    toggleSearch() {
      this.showSearch = !this.showSearch
    },
    /** 查看详情按钮操作 */
    handleView(row) {
      const id = row.id || this.ids
      getCustomer_records(id).then(response => {
        this.viewForm = response.data
        this.viewOpen = true
      })
    },
  }
}
</script>

<style lang="scss" scoped>
.app-container {
  padding: 20px;
  background-color: #f5f7fa;
  min-height: calc(100vh - 84px);
}

.stats-container {
  margin-bottom: 20px;
  
  .stat-card {
    border-radius: 12px;
    border: none;
    transition: all 0.3s ease;
    
    &:hover {
      transform: translateY(-5px);
      box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    }
    
    .stat-content {
      display: flex;
      align-items: center;
      padding: 10px;
      
      .stat-icon {
        width: 60px;
        height: 60px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-right: 15px;
        
        i {
          font-size: 24px;
          color: white;
        }
      }
      
      .stat-info {
        flex: 1;
        
        .stat-number {
          font-size: 28px;
          font-weight: bold;
          color: #303133;
          line-height: 1;
          margin-bottom: 5px;
        }
        
        .stat-label {
          font-size: 14px;
          color: #606266;
        }
      }
    }
    
    // 不同卡片类型的颜色
    &.total-card {
      .stat-icon {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
      }
    }
 
    &.visit-card {
      .stat-icon {
        background: linear-gradient(135deg, #0cebeb, #20e3b2);
      }
    }
    
    &.phone-card {
      .stat-icon {
        background: linear-gradient(135deg, #4776E6, #8E54E9);
      }
    }
    
    &.amount-card {
      .stat-icon {
        background: linear-gradient(135deg, #f46b45, #eea849);
      }
    }
  }
}

.search-card, .action-card, .data-card {
  border-radius: 12px;
  border: none;
  margin-bottom: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  
  .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    
    .card-title {
      font-size: 16px;
      font-weight: 600;
      color: #303133;
      
      i {
        margin-right: 8px;
        color: #409EFF;
      }
    }
    
    .card-subtitle {
      font-size: 13px;
      color: #909399;
    }
    
    .header-actions {
      display: flex;
      gap: 10px;
      .el-button {
        padding: 0;
        margin-left: 15px;
      }
    }
  }
}

.action-card {
  margin-bottom: 20px;
  border-radius: 12px;
  .action-buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    .left-buttons,
    .right-buttons {
      display: flex;
      gap: 10px;
      flex-wrap: wrap;
    }
  }
}

.data-card {
  border-radius: 12px;
  .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0;
    .card-title {
      font-size: 16px;
      font-weight: 600;
      color: #303133;
      i {
        margin-right: 8px;
        color: #409eff;
      }
    }
    .card-subtitle {
      font-size: 14px;
      color: #909399;
    }
  }
}

.custom-table {
  border-radius: 8px;
  overflow: hidden;
  ::v-deep .el-table__header th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #606266;
  }
  .customer-name,
  .contact-person,
  .contact-phone {
    display: flex;
    align-items: center;
    i {
      margin-right: 5px;
      color: #409EFF;
    }
  }
  .amount-text {
    font-weight: bold;
    color: #f56c6c;
  }
  .customer-source-tag {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    border: none !important;
    color: white !important;
    i {
      color: white !important;
    }
  }
}

::v-deep .el-dialog {
  border-radius: 12px;
  .el-dialog__header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px 12px 0 0;
    padding: 20px;
    .el-dialog__title {
      color: white;
      font-weight: 600;
    }
  }
  .el-dialog__body {
    padding: 20px;
  }
  .el-dialog__footer {
    padding: 15px 20px;
    border-top: 1px solid #ebeef5;
  }
  .el-tabs {
    box-shadow: none;
    border: none;
    ::v-deep .el-tabs__header {
      margin-bottom: 20px;
    }
    ::v-deep .el-tabs__nav-wrap::after {
      display: none;
    }
  }
}

::v-deep .el-form-item__label {
  font-weight: 500;
  color: #606266;
}

::v-deep .el-input__inner {
  border-radius: 8px;
  border: 1px solid #dcdfe6;
  transition: all 0.3s ease;
  &:focus {
    border-color: #409eff;
    box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.2);
  }
}

::v-deep .el-select .el-input__inner {
  border-radius: 8px;
}

::v-deep .el-textarea__inner {
  border-radius: 8px;
  border: 1px solid #dcdfe6;
  transition: all 0.3s ease;
  &:focus {
    border-color: #409eff;
    box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.2);
  }
}

::v-deep .el-tabs--border-card {
  border-radius: 8px;
  box-shadow: none;
  border: 1px solid #dcdfe6;
}
::v-deep .el-tabs--border-card>.el-tabs__header {
  background-color: #f5f7fa;
  border-bottom: 1px solid #dcdfe6;
}
::v-deep .el-tabs--border-card>.el-tabs__header .el-tabs__item {
  border-radius: 6px 6px 0 0;
  margin-right: 5px;
  &.is-active {
    background-color: #409eff;
    color: white;
    border-color: #409eff;
  }
}

::v-deep .el-button {
  border-radius: 8px;
  font-weight: 500;
  transition: all 0.3s ease;
  &.el-button--primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    &:hover {
      background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
      transform: translateY(-2px);
    }
  }
  &.el-button--success {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    border: none;
    &:hover {
      background: linear-gradient(135deg, #0f8a7d 0%, #2dd66e 100%);
      transform: translateY(-2px);
    }
  }
  &.el-button--danger {
    background: linear-gradient(135deg, #ff416c 0%, #ff4b2b 100%);
    border: none;
    &:hover {
      background: linear-gradient(135deg, #e63a5f 0%, #e64426 100%);
      transform: translateY(-2px);
    }
  }
  &.el-button--warning {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    border: none;
    &:hover {
      background: linear-gradient(135deg, #d884e2 0%, #d44e5f 100%);
      transform: translateY(-2px);
    }
  }
  &.el-button--info {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    border: none;
    &:hover {
      background: linear-gradient(135deg, #45a1f0 0%, #00e5f0 100%);
      transform: translateY(-2px);
    }
  }
}

::v-deep .el-tag {
  border-radius: 6px;
  font-weight: 500;
  &.el-tag--info {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
  }
}

::v-deep .el-pagination {
  margin-top: 20px;
  text-align: center;
}

.customer-detail {
  padding: 20px 0;
}
::v-deep .el-descriptions {
  .el-descriptions-item__label {
    font-weight: 600;
    color: #606266;
    background-color: #fafafa;
  }
  .el-descriptions-item__content {
    color: #303133;
  }
}

@media (max-width: 1200px) {
  .stats-container .el-col {
    margin-bottom: 20px;
  }
}
</style>